package com.atguigu.gulimall.product;


import com.atguigu.gulimall.product.service.CategoryService;
import lombok.extern.slf4j.Slf4j;
import org.junit.Test;
import org.junit.runner.RunWith;
import org.springframework.beans.factory.annotation.Autowired;
import org.springframework.boot.test.context.SpringBootTest;
import org.springframework.test.context.junit4.SpringJUnit4ClassRunner;
import org.springframework.test.context.junit4.SpringRunner;

import javax.annotation.Resource;
import java.util.Arrays;

@Slf4j
@RunWith(SpringRunner.class)
@SpringBootTest(classes = {GulimallProductApplication.class})
public class GulimallProductTestApplication {
    @Autowired
    private CategoryService categoryService;

    @Test
    public void testFindPath() {
        Long[] cateLogPath = categoryService.findCatelogPath(225L);
        log.info("完整路径：{}", Arrays.asList(cateLogPath));
    }

    @Test
    public void testChar() {
        //方式一  精度会有缺失,如果是13.0就没有问题
        String aaa = "13.1";

        Double bbb = Double.valueOf(aaa);
        Integer ccc = bbb.intValue();
        log.info("String类型：{}", bbb);
        log.info("String转Inter类型：{}", ccc);
        //方式二  不会产生精度的缺失
        String ddd = aaa.substring(0, aaa.length() - 2);//截掉最后2位,保留前面的
        //区分
        String strh = aaa.substring(aaa.length() - 2, aaa.length());   //截取掉
        int parseInt = Integer.parseInt(ddd);

        log.info("String转Inter类型：{}", parseInt);

    }
}

